package com.platform.eureka;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

@SpringBootApplication
@EnableEurekaServer
public class EurekaApplication {

    /**
     * 注意：生成环境下建议搭建3个 实例的EurekaServer对等集群，这里我们只搭建1个。
     * 在命令行中输入
     * Windows
     * java -jar eureka-server-1.0.0.jar
     * Linux
     * nohup java -jar eureka-server-1.0.0.jar > eureka-server.out &
     * 注意：每个机器上指定的active不一样
     *
     * @param args
     */
    public static void main(String[] args) {
        SpringApplication.run(EurekaApplication.class, args);
    }

    /**
     * 放开客户端注册验证权限
     */
    @EnableWebSecurity
    static class WebSecurityConfig extends WebSecurityConfigurerAdapter {
        @Override
        protected void configure(HttpSecurity http) throws Exception {
            http.csrf().ignoringAntMatchers("/eureka/**");//.disable();//
            super.configure(http);
        }
    }
}
